﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Operators.CMOperators;
using Operators;
using Common;

namespace Satates.CMStates
{
    public class CMState : Template
    {
        private int LeftCanibals;
        private int RightCanibals;
        private int LeftMissionaries;
        private int RightMissionaries;
        private String boat = "right";
        private Template s;

        public static State initalState()
        {
            return new State(new CMState(0, 0, 3, 3, "right"),(iOperator)new InitialState());
        }

        public static List<State> finalStates()
        {
            List<State> fStates = new List<State>();
            fStates.Add(new State(new CMState(3, 3, 0, 0, "left"), null));
            return fStates;
        }

        public CMState(CMState s)
        {
            LeftCanibals = s.LeftCanibals;
            RightCanibals = s.RightCanibals;
            LeftMissionaries = s.LeftMissionaries;
            RightMissionaries = s.RightMissionaries;
            boat = s.boat;
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
        public string getBoat()
        {
            return boat;
        }

        public void setBoat(String boat)
        {
            this.boat = boat;
        }
        
        public CMState(int leftCanibals, int leftMissionaries, int rightCanibals,
                int rightMissionaries, String boat)
        {
            LeftCanibals = leftCanibals;
            RightCanibals = rightCanibals;
            LeftMissionaries = leftMissionaries;
            RightMissionaries = rightMissionaries;
            this.boat = boat;
        }

       
        
        public int getLeftCanibals()
        {
            return LeftCanibals;
        }
        public void setLeftCanibals(int leftCanibals)
        {
            LeftCanibals = leftCanibals;
        }
        public int getRightCanibals()
        {
            return RightCanibals;
        }
        public void setRightCanibals(int rightCanibals)
        {
            RightCanibals = rightCanibals;
        }
        public int getLeftMissionaries()
        {
            return LeftMissionaries;
        }
        public void setLeftMissionaries(int leftMissionaries)
        {
            LeftMissionaries = leftMissionaries;
        }
        public int getRightMissionaries()
        {
            return RightMissionaries;
        }
        public void setRightMissionaries(int rightMissionaries)
        {
            RightMissionaries = rightMissionaries;
        }

        public override string ToString()
        {
            string LeftString = "Left Side: Canibals: ";
            string RightString = "Right Side: Canibals: ";
            LeftString += this.getLeftCanibals();
            LeftString += " Missionaries: ";
            LeftString += this.getLeftMissionaries();
            RightString += this.getRightCanibals();
            RightString += " Missionaries: ";
            RightString += this.getRightMissionaries();

            return LeftString + " ~ " + RightString + " boat is " + this.getBoat();
        }
    }
}
